--- mkinitrd.dist	2017-06-29 19:11:26.000000000 +0200
+++ mkinitrd	2017-09-14 17:06:37.162295307 +0200
@@ -48,6 +48,9 @@
 #   to add support for TRIM on LUKS root devs 
 # Modified by Patrick Volkerding <volkerdi@slackware.com> 29 June 2017
 #   Add support for prepending a microcode update archive (-P).
+# Modified by Marek Wodzinski <majek@mamy.to> 14 September 2017
+#   Added copying of thin-provisioning-tools if available and LVM
+#   support enabled. It's required to start root volume with dm-cache.
 
 MKINITRD_VERSION=1.4.10
 
@@ -562,6 +565,14 @@
     ( cd $SOURCE_TREE/sbin
       ln -s lvm vgchange 2>/dev/null
       ln -s lvm vgscan 2>/dev/null )
+    # Include thin-provisioning-tools (dm-cache and dm-thin support)
+    if [ -f /usr/sbin/pdata_tools ]; then
+      PDATA_BASEDIR=/usr/sbin	#it should be in /sbin, but default Slackware lvm2 is compiled with path to /usr/sbin :-(
+      mkdir -p $SOURCE_TREE/$PDATA_BASEDIR
+      cp $PDATA_BASEDIR/pdata_tools $SOURCE_TREE/$PDATA_BASEDIR/pdata_tools
+      ( cd $SOURCE_TREE/$PDATA_BASEDIR
+        find $PDATA_BASEDIR -lname pdata_tools | xargs -n1 basename | xargs -n1 ln -s pdata_tools 2>/dev/null )
+    fi
   else
     echo "LVM binary is missing, LVM support isn't installed"
     LVM=""
